<?php

	class Mod_entradas extends CI_Model{

		function __construct()
		{
			parent::__construct();
		}


		function inserir_entrada($id, $id_user)
		{
			$query_str1 = "INSERT INTO inscricoes (u_id, g_id) VALUES (?, ?)";
			//$query_str1 = "UPDATE giveaway SET g_entradas = g_entradas + 1 WHERE g_id = $id";
			$result1 = $this->db->query($query_str1, array($id_user, $id));
			//$result1 = $this->db->query($query_str1);

			$query_str2 = "SELECT g_id FROM inscricoes WHERE g_id = $id";
			$result2 = $this->db->query($query_str2);

			return($result2->num_rows());
		}

		function pesquisa_entrada($id)
		{
			$query_str2 = "SELECT g_id FROM inscricoes WHERE g_id = $id";
			$result2 = $this->db->query($query_str2);

			return($result2->num_rows());
		}

		function pesquisa_entrada_user($id_user)
		{
			$query_str2 = "SELECT g_id FROM inscricoes WHERE u_id = $id_user";
			$result2 = $this->db->query($query_str2);

			return $result2->result();
		}

	}

?>